package interview.base;

public class CopyDemo2 {

    public static void main(String[] args) {

    }
}
 class Text2 implements Cloneable{

    private int age;

    private Name name;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Name getName() {
        return name;
    }

    public void setName(Name name) {
        this.name = name;
    }

    @Override
    protected Object clone(){
        Text2 text2=null;
        try {
            text2=(Text2) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        //text2.setName((Name2) text2.getName().clone());
        return text2;
    }


}

class Name2 implements Cloneable{
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    protected Object clone() {
        try {
            return super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }
}


